<template>
  <van-pull-refresh v-model="formData.loading" @refresh="onRefresh">

    <ul v-if="DataList.length>=1">
      <li v-for="(item,index) in DataList" :key="index" @click="GoDetail(item.userCollectionId)">
        <div class="li">
          <van-row class="flex">
            <van-col span="8">
              <div class="img-warp">
                <img :src="item.collection.cover" alt="">
              </div>

            </van-col>
            <van-col span="16">
              <div class="record-cont">
                <h1>
                  {{item.collection.name}}
                </h1>
                <div class="record-box">
                  {{item.collection.createTime?item.collection.createTime:""}}
                  <!-- <span>编号</span>
                  <span>{{item.antsCollectionVO.code}}</span> -->
                </div>
              </div>
            </van-col>

          </van-row>
          <!-- <p> {{item.antsCollectionVO.createTime?item.antsCollectionVO.createTime:""}}</p> -->
        </div>
      </li>
    </ul>
    <van-empty :image="require('@/assets/image/none.png')" description="暂无记录" v-if="DataList.length<=0" />
  </van-pull-refresh>

</template>
<script>
import { ref, defineComponent, reactive, onMounted, toRefs, nextTick } from "vue";
import { collectionList, mix } from "@/api/public";
import { Toast } from "vant";
import { useRouter } from 'vue-router'
export default defineComponent({
  setup() {
    const router = useRouter()
    const DataList = ref([])
    const formData = reactive({
      page: 1,
      size: 10,
      active: 0,
      type: 0,
      loading: false,

    })
    const onRefresh = () => {
      Toast('刷新成功');
      formData.loading = false;
      onload()

    }
    const GoDetail = (id) => {
      router.push({
        path: '/listinfo',
        query: {
          id: id
        }
      })
    }
    const onClickTab = (index) => {
      DataList.value = []

      formData.type = index

      onload()

    }
    onMounted(() => {
      onload()
    })
    const onload = () => {
      const data = { type: formData.type }
      mix(formData).then(res => {
        if (!res.data.success) {

        } else {
          DataList.value = res.data.data.records

        }


      })

    }
    const tabList = reactive([
      {
        id: 0,
        name: '全部'
      },
      {
        id: 0,
        name: '进行中'
      },
      {
        id: 0,
        name: '已完成'
      },
      {
        id: 0,
        name: '已取消'
      },


    ])
    return {
      tabList,
      formData,
      onRefresh,
      DataList,
      onClickTab,
      GoDetail
    }
  }

})
</script>
<style lang="less" scoped>
&:deep(.van-icon-arrow) {
  font-size: 45px;
  position: absolute;
  right: 5%;
  color: #fff;
  top: 37%;
}
ul {
  // background: #292b2a;
  width: 100%;
  margin: 0.5rem auto;
  border-radius: 8px;

  li {
    position: relative;
    background-size: 100% 100%;
    height: 100%;
    margin: 0px 30px 30px;
    padding: 10px;
    background: #282a2c;
    border-radius: 20px;
    .li {
      border-radius: 20px;

      &:deep(.van-col) {
        height: 100%;
        display: block;
        text-align: center;
      }
      p {
        text-align: right;
      }
      display: flex;
      flex-direction: column;
      width: 100%;
      height: 100%;
      .flex {
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
        height: 100%;
        .record-cont {
          position: relative;
          padding-top: 0%;
          padding-left: 8%;
          width: 100%;
          height: 100%;
          h1 {
            text-align: left;
            color: white;
            margin: 0;
            font-weight: normal;
            font-size: 34px;
          }
          &:deep(.van-col--6) {
            text-align: right;
          }

          .right {
            display: flex;
            justify-content: flex-end;
            color: green !important;
          }
          .record-box {
            height: 25px;
            font-size: 26px;
            font-family: Source Han Sans CN;
            font-weight: 400;
            color: #b9c4c7;
            display: flex;
            align-items: center;
            margin-top: 0.5rem;
            span {
              display: inline-block;
              font-size: 30px;
              width: fit-content;
              padding: 10px 20px;
              text-align: center;
            }
            span:nth-child(1) {
              background: #ffc569;
              color: #292b2a;
              border-radius: 6px 0px 0px 6px;
            }
            span:nth-child(2) {
              background: #4a4b4d;
              color: #fff;
              border-radius: 0px 6px 6px 0px;
            }
          }
        }

        h1 {
          color: white;
          margin: 0;
          font-weight: normal;
          font-size: 36px;
        }
      }
      .line {
        // border-bottom: 1px solid #999999;
      }
    }
    img {
      width: 2.5rem;
      height: 2.5rem;
      border-radius: 6px;
    }
    display: block;

    .cont {
      width: 100%;
      display: flex;
      flex-direction: column;
      align-items: center;
      display: block;
      margin-left: 3%;
      span {
        width: 100%;
        color: #b48457;
        position: relative;
        font-size: 30px;
        padding-left: 5%;
        margin-right: 15px;
      }
      .flex {
        color: white;
        display: flex;
        //超出两行省略号
        margin: 0px;
        width: 80%;
        text-overflow: -o-ellipsis-lastline;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;
      }
      p {
        margin-top: 1rem;
      }
      span::before {
        position: absolute;
        content: '';
        left: 0px;
        width: 6px;
        height: 30px;
        background: #b48457;
      }
    }
    p {
      color: #999999;
      font-size: 30px;
    }
  }
}
&:deep(.van-tabs__line) {
  background: linear-gradient(to top, #d4954d, #ffdbb4);
}
&:deep(.van-tabs__nav) {
  width: 90%;
  background: #292b2a;
  margin: 0 auto;
}
&:deep(.van-tab__text) {
  color: white;
  font-size: 0.45rem;
}
&:deep(.van-tab--active span) {
  color: #b48457;
}
</style>